package com.go.where.manager.page;

import java.io.Serializable;

import com.go.where.manager.common.Constants;

/**
 * 分页基类
 * 
 * 
 */
public class BaseQuery implements Serializable {

	// 排序方式
	public enum OrderType {
		asc, desc
	}

	private static final long serialVersionUID = 3165341447763021203L;

	private Integer pageStart;
	private Integer pageEnd;

	private Integer pageSize;// 每页记录数
	private Integer currentPage;// 当前页数

	private String orderBy = "";// 排序字段
	private OrderType orderType = OrderType.desc;// 排序方式

	private String page_orderByAsc;
	private String page_orderByDesc;

	public BaseQuery() {
		calculate();
	}

	public BaseQuery(Integer pageStart, Integer pageEnd) {
		this.pageStart = pageStart;
		this.pageEnd = pageEnd;
	}

	public void calculate() {
		if (pageSize != null && currentPage != null) {
			this.pageStart = (currentPage - 1) * pageSize + 1;
			this.pageEnd = currentPage * pageSize;
		} else {
			pageSize = Constants.INIT_PAGESIZE;
			currentPage = Constants.INIT_CURRENTPAGE;
		}

	}

	public Integer getPageStart() {
		return pageStart;
	}

	public void setPageStart(Integer pageStart) {
		this.pageStart = pageStart;
	}

	public Integer getPageEnd() {
		return pageEnd;
	}

	public void setPageEnd(Integer pageEnd) {
		this.pageEnd = pageEnd;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public OrderType getOrderType() {
		return orderType;
	}

	public void setOrderType(OrderType orderType) {
		this.orderType = orderType;
	}

	public String getPage_orderByAsc() {
		return page_orderByAsc;
	}

	public void setPage_orderByAsc(String pageOrderByAsc) {
		page_orderByAsc = pageOrderByAsc;
	}

	public String getPage_orderByDesc() {
		return page_orderByDesc;
	}

	public void setPage_orderByDesc(String pageOrderByDesc) {
		page_orderByDesc = pageOrderByDesc;
	}

}
